<?php

namespace App\Jobs;

use App\Services\EasyWeChatServices;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\Order;
use App\Models\WxPayRecord;
use App\Http\Controllers\Api\NotifyController;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class Refund implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($order_id,$wx_pay_record_id)
    {
        $this->order_id = $order_id;
        $this->wx_pay_record_id = $wx_pay_record_id;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        try {
            DB::beginTransaction();
            $orderObj = Order::where('id',$this->order_id)->first();
            $wx_orderObj = WxPayRecord::where('id',$this->wx_pay_record_id)->first();
            if($orderObj->order_status == 3 && $wx_orderObj->status ==3){
                $EasyWechatService = app('EasyWeChatServices');
                //$EasyWechatService->Re
            }

        } catch (\Exception $exception) {

        }
    }
}
